// pages/my/invoice/get.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs:[{name:'可开发票'},{name:'历史开票'},{name:'抬头管理'}],
    radioItems:[{name:'公司',value: "2"},{name:'个人/非企业单位',value: "1"}],
    ids:'',
    price:'',
    sub_info:{ids:'',price:'',type:"2",tt:"",code:'',bankname:'',bankcode:'',address:'',tel:''},
  },
  onLoad(options) {
    this.setData({
      ids:options.ids
    })
    this.load();
  },
  setInput(e){
    let key=e.currentTarget.dataset.key;
    let val=e.detail.value;
    this.setData({
      [key]:val
    })
  },
  async load(){
    let res=await wx.util.post("fp/info",{ids:this.data.ids});
    this.setData({
      price:res.data.price
    })
    if(res.data.fp){
      this.setData({
        sub_info:res.data.fp
      })
    }
  },
  async subInfo(){
    this.setData({
      'sub_info.ids':this.data.ids,
      'sub_info.price':this.data.price
    })
    await wx.util.post("fp/sub",this.data.sub_info,false);
    wx.util.toast('提交成功');
    setTimeout(()=>{
      wx.navigateBack({
        delta:1
      })
    },1000)
  }
})